package com.wbw.controller;

import com.wbw.api.Flight;
import com.wbw.api.FlightService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;

@RestController
@RequestMapping
@Slf4j
public class FlightController {

    @Reference
    private FlightService flightService;

    @GetMapping("/flights")
    public List<Flight> getAllFlights() {
        log.info("查询所有的航班信息！");
        return flightService.getAllFlights();
    }

    @GetMapping("/flights/beijing")
    public List<Flight> getFlightsFromBeijing() {
        log.info("查询北京起飞的航班信息！");
        return flightService.getFlightsFromBeijing();
    }

    @GetMapping("/flights/shanghai")
    public List<Flight> getFlightsToShanghai() {
        log.info("查询去上海的航班信息！");
        return flightService.getFlightsToShanghai();
    }

    @GetMapping("/flights/earlymorning/shanghai")
    public List<Flight> getEarlyMorningFlightsFromShanghai() {
        log.info("查询从上海出发的早航班信息！");
        return flightService.getEarlyMorningFlightsFromShanghai();
    }

}